<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
        table {
            margin: 100px auto;
            border-collapse: collapse;
            width: 500px;
            font-size: 14px;
            text-align: center;
        }
        thead tr {
            background-color: #ccc;
            height: 40px;
        }
        td, th {
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <table border="1px">
        <thead>
            <tr>
                <th>姓名</th>
                <th>科目</th>
                <th>成绩</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
    <script>
        var datas = [{
            name: '明达',
            subject: 'JavaScript',
            score: 100
        }, {
            name: '小邸',
            subject: 'JavaScript',
            score: 98
        }, {
            name: '小明',
            subject: 'JavaScript',
            score: 99
        }, {
            name: '明达大',
            subject: 'JavaScript',
            score: 88
        }, {
            name: '大猪蹄子',
            subject: 'JavaScript',
            score: 0
        }];
        var tbody = document.querySelector('tbody');
        // 循环人数
        for(var i = 0; i < datas.length; i++){
            // 创建行，插入tbody
            var tr = document.createElement('tr');
            tbody.appendChild(tr);
            student = datas[i];
            // 循环属性，插入行
            for(var k in student){
                var td = document.createElement('td');
                td.innerHTML = student[k];
                tr.appendChild(td);
            }
            var td = document.createElement('td');
            td.innerHTML = '<a href="javascript:;">删除 </a>';
            tr.appendChild(td);
        }

        var as = document.querySelectorAll('a');
        for(var i = 0; i < as.length; i++) {
            as[i].onclick = function() {
                tbody.removeChild(this.parentNode.parentNode)
            }
        }
    </script>
</body>
</html>